<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>Channel (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>

  <script type="text/javascript" src="//www.google.com/jsapi"></script>
  <script type="text/javascript">
     google.load("visualization", "1", {packages:["orgchart"]});
     var _loadingVisualizations = true;
  </script>

  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">labs.net.webChannel.Channel</span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Shared interface between Channel and TestChannel to support callbacks
between WebChannelBase and BaseTestChannel and between Channel and
ChannelRequest.


  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="local_closure_goog_labs_net_webchannel_channel.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/labs/net/webchannel/channel.js">Git</a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
  <tr><td>goog.labs.net.webChannel.Channel</td><td></td></tr>
</table>
</div>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
</table>
</div>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.labs.net.webChannel.Channel(<span></span>)
  </div>



<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="interface_goog_labs_net_webChannel_Channel.html">
              goog.labs.net.webChannel.Channel
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.correctHostPrefix"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">correctHostPrefix<span class="args">(<span class="arg">serverHostPrefix</span>)</span>
        </span>
        &#8658; <span>?</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
      </div>


     <div class="entryOverview">
       Not needed for testchannel.

Allows the handler to override a host prefix provided by the server.  Will
be called whenever the channel has received such a prefix and is considering
its use.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">serverHostPrefix</span>
        : <span>?</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The host prefix provided by the server.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>?</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&nbsp;
            The host prefix the client should use.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line140">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.createDataUri"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">createDataUri<span class="args">(<span class="arg">hostPrefix</span>,&nbsp;<span class="arg">path</span>,&nbsp;<span class="arg">opt_overridePort</span>)</span>
        </span>
        &#8658; <span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span>
      </div>


     <div class="entryOverview">
       Not needed for testchannel.

Creates a data Uri applying logic for secondary hostprefix, port
overrides, and versioning.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">hostPrefix</span>
        : <span>?</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The host prefix.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">path</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The path on the host (may be absolute or relative).</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_overridePort</span>
        : <span class="type">number=</span>
        <div class="entryOverview">Optional override port.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span>&nbsp;
            The data URI.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line153">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.createXhrIo"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">createXhrIo<span class="args">(<span class="arg">hostPrefix</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="class_goog_net_XhrIo.html">goog.net.XhrIo</a></span>
      </div>


     <div class="entryOverview">
       Called when creating an XhrIo object.  Override in a subclass if
you need to customize the behavior, for example to enable the creation of
XHR's capable of calling a secondary domain. Will also allow calling
a secondary domain if withCredentials (CORS) is enabled.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">hostPrefix</span>
        : <span>?</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The host prefix, if we need an XhrIo object
    capable of calling a secondary domain.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="class_goog_net_XhrIo.html">goog.net.XhrIo</a></span>&nbsp;
            A new XhrIo object.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line75">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.getBackChannelUri"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getBackChannelUri<span class="args">(<span class="arg">hostPrefix</span>,&nbsp;<span class="arg">path</span>)</span>
        </span>
        &#8658; <span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span>
      </div>


     <div class="entryOverview">
       Not needed for testchannel.

Gets the Uri used for the connection that receives data from the server.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">hostPrefix</span>
        : <span>?</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The host prefix.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">path</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The path on the host.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span>&nbsp;
            The back channel URI.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line128">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.getConnectionState"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getConnectionState<span class="args">()</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="class_goog_labs_net_webChannel_ConnectionState.html">goog.labs.net.webChannel.ConnectionState</a></span>
      </div>


     <div class="entryOverview">
       Not needed for testchannel.
Gets the result of previous connectivity tests.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="class_goog_labs_net_webChannel_ConnectionState.html">goog.labs.net.webChannel.ConnectionState</a></span>&nbsp;
            The connectivity state.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line185">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.getForwardChannelUri"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getForwardChannelUri<span class="args">(<span class="arg">path</span>)</span>
        </span>
        &#8658; <span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span>
      </div>


     <div class="entryOverview">
       Not needed for testchannel.

Gets the Uri used for the connection that sends data to the server.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">path</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The path on the host.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span>&nbsp;
            The forward channel URI.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line117">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.isActive"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">isActive<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       Gets whether this channel is currently active. This is used to determine the
length of time to wait before retrying. This call delegates to the handler.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            Whether the channel is currently active.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line107">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.isClosed"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">isClosed<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       Returns whether the channel is closed

     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            true if the channel is closed.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line90">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.onRequestComplete"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">onRequestComplete<span class="args">(<span class="arg">request</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Callback from ChannelRequest that indicates a request has completed.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">request</span>
        : <span>!</span><span class="type"><a href="class_goog_labs_net_webChannel_ChannelRequest.html">goog.labs.net.webChannel.ChannelRequest</a></span>
        <div class="entryOverview">The request object.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line83">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.onRequestData"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">onRequestData<span class="args">(<span class="arg">request</span>,&nbsp;<span class="arg">responseText</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Callback from ChannelRequest for when new data is received

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">request</span>
        : <span class="type"><a href="class_goog_labs_net_webChannel_ChannelRequest.html">goog.labs.net.webChannel.ChannelRequest</a></span>
        <div class="entryOverview">The request object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">responseText</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The text of the response.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line99">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.shouldUseSecondaryDomains"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">shouldUseSecondaryDomains<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       Determines whether to use a secondary domain when the server gives us
a host prefix. This allows us to work around browser per-domain
connection limits.

Currently, we  use secondary domains when using Trident's ActiveXObject,
because it supports cross-domain requests out of the box.  Note that in IE10
we no longer use ActiveX since it's not supported in Metro mode and IE10
supports XHR streaming.

If you need to use secondary domains on other browsers and IE10,
you have two choices:
    1) If you only care about browsers that support CORS
       (<a href="https://developer.mozilla.org/en-US/docs/HTTP_access_control">https://developer.mozilla.org/en-US/docs/HTTP_access_control</a>), you
       can use <code> #setSupportsCrossDomainXhrs</code> and set the appropriate
       CORS response headers on the server.
    2) Or, override this method in a subclass, and make sure that those
       browsers use some messaging mechanism that works cross-domain (e.g
       iframes and window.postMessage).


     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            Whether to use secondary domains.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line63">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.testConnectionFailure"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">testConnectionFailure<span class="args">(<span class="arg">testChannel</span>,&nbsp;<span class="arg">errorCode</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Not needed for testchannel.

Callback from TestChannel for when the channel has an error.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">testChannel</span>
        : <span class="type"><a href="class_goog_labs_net_webChannel_BaseTestChannel.html">goog.labs.net.webChannel.BaseTestChannel</a></span>
        <div class="entryOverview">The TestChannel.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">errorCode</span>
        : <span class="type">goog.labs.net.webChannel.ChannelRequest.Error</span>
        <div class="entryOverview">The error code of the failure.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line176">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.webChannel.Channel.prototype.testConnectionFinished"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">testConnectionFinished<span class="args">(<span class="arg">testChannel</span>,&nbsp;<span class="arg">useChunked</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Not needed for testchannel.

Callback from TestChannel for when the channel is finished.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">testChannel</span>
        : <span class="type"><a href="class_goog_labs_net_webChannel_BaseTestChannel.html">goog.labs.net.webChannel.BaseTestChannel</a></span>
        <div class="entryOverview">The TestChannel.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">useChunked</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
        <div class="entryOverview">Whether we can chunk responses.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_webchannel_channel.js.source.html#line164">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




















<div class="section">
  <table class="horiz-rule">


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package labs.net.webChannel</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="labs.net.webChannel.Channel"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
